package com.igeek.boot.controller;

import com.igeek.boot.result.Result;
import com.igeek.boot.service.SeckillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @Author fengqq
 * @Description TODO
 * @Date 2024/9/6  14:35
 */
@RestController
@RequestMapping("/kill")
@Api(tags = "秒杀案例的接口")
@Slf4j
public class SeckillController {

    @Autowired
    private SeckillService seckillService;

    @GetMapping("")
    @ApiOperation("秒杀商品")
    public Result kill(Integer pid){
        //生成uid
        String uid = UUID.randomUUID().toString();
//        Result result = seckillService.kill(pid,uid);killByTrans
//        Result result = seckillService.killByTrans(pid,uid);
        Result result = seckillService.killByLua(pid, uid);
        return result;
    }
}
